package lab04;
import java.util.Scanner;

// 求 n 的阶乘 factorial of n n!，n 为用户输入的正整数
public class Factorial {

    // 0! = 1, 1! = 1, 2! = 2...

    private static long getFactorial(int n) {
        if (n == 0) {
            return 1;
        }
        return n * getFactorial(n - 1);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("input n: ");
        int n = scanner.nextInt();
        System.out.println(n + "! = " + getFactorial(n));
    }
}